//
//  STXYChooserCell.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/11/21.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "STXYChooserCell.h"

@interface STXYChooserCell ()

/// viewModle
@property (nonatomic, readwrite, strong) STXYChooserCellModel *viewModel;

/// IBOutlet
@property (weak, nonatomic) IBOutlet UILabel* contentLabel;
@property (weak, nonatomic) IBOutlet UIButton* chooserBtn;

@end

@implementation STXYChooserCell

- (void)awakeFromNib
{
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

#pragma mark - bind data
- (void)bindViewModel:(STXYChooserCellModel *)viewModel
{
    self.viewModel = viewModel;
    
    @weakify(self);
    
    self.contentLabel.text = self.viewModel.content;
    
    RAC(self.chooserBtn, enabled) = [[RACObserve(self.viewModel, isChoose) map:^id(id value)
    {
        bool isChoose = [value boolValue];
        
        return @(!isChoose);
    }] takeUntil:[self rac_prepareForReuseSignal]];
}

@end
